package demo.standard;

public class Originator {
    private String state;
    private String id;

    public Originator(String id, String state) {
        this.id = id;
        this.state = state;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Originator{" +
                "state='" + state + '\'' +
                ", id='" + id + '\'' +
                '}';
    }

    public Memento createMemento() {
        Memento memento = new Memento();
        memento.setState(this.getState());
        return memento;
    }

    public void restore(Memento memento) {
        setState(memento.getState());
    }
}
